using Microsoft.VisualStudio.TestTools.UnitTesting;
using E = com.bodurov.SilverlightControls.XmlCodeEditor.Enums.XmlElement;
using A = com.bodurov.SilverlightControls.XmlCodeEditor.Enums.XmlArea;

namespace com.bodurov.SilverlightControls.XmlCodeEditor.Tests
{
    [TestClass]
    public class SplitTokenizerCanParseSimpleTags : BaseTokenFixture
    {
        [TestMethod]
        public void Can_Parse_Simple_Break_Tag()
        {
            const string str = "<br />";

            var tokenizer = new SplitTokenizer();
            var tokens = tokenizer.ParseTokens(str);

            TraceTokens(tokens);

            AssertTokens(tokens,
                Within(A.InsideTag,
                    Expect("<", E.OpeningTagBeginBracket),
                    Expect("br", E.OpeningTagName),
                    Expect(" ", E.WhiteSpace),
                    Expect("/>", E.OpeningTagClosingBracket)));
        }
        [TestMethod]
        public void Can_Parse_Server_Declaration_Tag()
        {
            const string str = "<%@ Page Language=\"C#\" \r\n     AutoEventWireup=\"false\" %>";

            var tokenizer = new SplitTokenizer();
            var tokens = tokenizer.ParseTokens(str);

            TraceTokens(tokens);

            AssertTokens(tokens,
                Within(A.InsideServerDeclaration,
                    Expect("<%@", E.OpeningServerScriptBracket),
                    Expect(" ", E.WhiteSpace),
                    Expect("Page", E.AttributeName),
                    Expect(" ", E.WhiteSpace),
                    Expect("Language", E.AttributeName),
                    Expect("=", E.AttributeEqualSign)),
                Within(A.InsideServerDeclaration | A.InsideDualQuoteString,
                    Expect("\"C#\"", E.AttributeDualQuoteString)),
                Within(A.InsideServerDeclaration,
                    Expect(" ", E.WhiteSpace),
                    Expect_NewLine,
                    Expect("     ", E.WhiteSpace),
                    Expect("AutoEventWireup", E.AttributeName),
                    Expect("=", E.AttributeEqualSign)),
                Within(A.InsideServerDeclaration | A.InsideDualQuoteString,
                    Expect("\"false\"", E.AttributeDualQuoteString),
                    Expect(" ", E.WhiteSpace),
                    Expect("%>", E.ClosingServerScriptBracket)));
        }
    }
}